﻿using Abp.Localization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace AbpProjectTemplate.Application.Shared
{
    public class LocalizationTestAppService : ApplicationService
    {
        private readonly ILanguageManager _languageManager;
        private readonly ILocalizationManager _localizationManager;

        public LocalizationTestAppService(ILanguageManager languageManager, ILocalizationManager localizationManager)
        {
            this._languageManager = languageManager;
            this._localizationManager = localizationManager;
        }



        public dynamic GetLanguages()
        {
            return this._languageManager.GetLanguages();
        }

        public dynamic GetAppLanguageTexts()
        {
            return this._localizationManager.GetAllSources()
                .Select(x => new
                {
                    source = x.Name,
                    values = x.GetAllStrings()
                });
        }

        public string GetCurrentCulture()
        {
            return CultureInfo.CurrentCulture.Name;
        }

        public IActionResult ChangeCluture(string name)
        {
            return new RedirectResult($"/AbpLocalization/ChangeCulture?cultureName={name}");
        }
    }
}
